<template>
  <div class="">
    <history
      @searchChange="searchChange"
      @gain="gain"
      :downIndex="downIndex"
    ></history>
    <ul>
      <li v-for="(v, i) in obj" :key="i">{{ v.goods_name }}</li>
    </ul>
  </div>
</template>

<script setup>
import history from "../components/history.vue";
import { ref } from "vue";
import { useStore } from "vuex";
import axios from "axios";
let searchValue = ref("");
let obj = ref([]);
let store = useStore();
async function searchChange(e) {
  let { data } = await axios.get("data.json");
  obj.value = data.filter((irem) => irem.goods_name.includes(e));
  store.commit("history", e);
}

components: {
  history;
}
</script>

<style lang="scss" scoped></style>
